import java.util.Arrays;

public class stringSort {
    public static void main(String[] args) {
        String str = "fabvqejhnfsfdqwefg";
        System.out.println(stringsort(str));
        int[] a = {5,34,6,1,466,8,4,-9};
        quicksort(a,0,a.length-1);
        System.out.println(Arrays.toString(a));
    }
    static String stringsort(String str){
        char[] list = str.toCharArray();
        quicksort(list,0,list.length-1);
        return new String(list);
    }
    static void quicksort(char[] list,int left,int right){
        if (left<right){
            int i=left;
            int j=right;
            while (i!=j){
                while (i<j&&list[j]>=list[left]){
                    j--;
                }
                while (i<j&&list[i]<=list[left]){
                    i++;
                }
                change(list,i,j);
            }
            change(list,left,j);
            quicksort(list,left,j-1);
            quicksort(list,j+1,right);
        }
    }
    static void quicksort(int[] list,int left,int right){
        if (left<right){
            int i=left;
            int j=right;
            while (i!=j){
                while (i<j&&list[j]>=list[left]){
                    j--;
                }
                while (i<j&&list[i]<=list[left]){
                    i++;
                }
                change(list,i,j);
            }
            change(list,left,j);
            quicksort(list,left,j-1);
            quicksort(list,j+1,right);
        }
    }
    static void change(char[] list,int i,int j){
        char temp = list [j];
        list[j]=list[i];
        list[i]=temp;
    }
    static void change(int[] list,int i,int j){
        int temp = list [j];
        list[j]=list[i];
        list[i]=temp;
    }
}
